/**
 * Admin category jquery
 *
 * date 2015-03-03
 * @author Yongtae Kim
 * @version 1.0.0
 */


/**
 * category treegrid click event
 */
$("table.tree tr").click(function() {
	var btnGroup = '';

	//alert(event.type + ": " + $(this).attr("id"));

	if( !$(this).hasClass("tree-selected") ) {

		// init innerHTML;
		btnGroup += '<div class="btn-toolbar">';
		btnGroup += '<div class="btn-group">';
		btnGroup += '<button type="button" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-wrench"></span></button>';
		btnGroup += '<button type="button" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-plus"></span></button>';
		btnGroup += '<button type="button" class="btn btn-default btn-xs"><span class="glyphicon glyphicon-trash"></span></button>';
		btnGroup += '</div>';
		btnGroup += '</div>';

		// selected clear;
		$("table.tree tr").each(function() {
			$(this).removeClass("tree-selected");
			$(this).children().get(1).innerHTML = '';
		});

		// selected add;
		$(this).addClass("tree-selected");

		// innerHTML add;
		$(this).children().get(1).innerHTML = btnGroup;
	}
});


/**
 * category page ready event
 */
$(document).ready(function() {
	$('.tree').treegrid();
});